Invention relates to microprocessor design and related signal processing circuit and logic, particularly to technique for reducing taken branch penalty by converting branches to jumps.
Conventional microprocessor design employs various logic for causing branching or redirection effectively of instruction or signal processing flow. For example, a target of a taken branch may be calculated from a given offset value relative to an address of the particular branch instruction. However, such calculation requires an additional step, thereby wasting processor cycles and degrading performance. Thus, because branches occur often during program execution, it is desirable to provide improved branching approach.
Invention pre-calculates target of conditional branch before branch is encountered, thereby reducing penalty in taking branch in pipelined processor by converting branches to jumps. During program execution, pipeline penalty is reduced effectively to that of unconditional jump. In particular, offset bits may be replaced in conditional branch using index bits according to offset bits addition and program counter value. Scheme may be applied during cache fill or dead cycle when taken branch is read from pipelined cache.
Preferably, all branches are translated into jump-instruction format by changing offset field of all branch instructions into an index field, and setting flag bit that accompanies the instruction to signify whether target calculation is complete. Such approach may avoid taken branch penalty, in many cases, leaving a penalty only when index calculation results in target of the branch residing in page adjacent to branch itself.